package cn.bytecollege.admin.service;

import cn.bytecollege.admin.dao.UserDao;
import cn.bytecollege.common.dao.BaseDao;
import cn.bytecollege.common.entity.Page;
import cn.bytecollege.common.entity.User;

import java.util.List;


public class UserService extends BaseDao {
    private UserDao userDao = null;
    public UserService() {userDao = new UserDao();}


    /**
     * 分页查询用户信息
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public Page<User> findUserByPage(int pageIndex,int pageSize){
        List<User> list = userDao.findUserByPage(pageIndex,pageSize);
        //查询用户总数
        int count = userDao.count();
        //封装page
        Page<User> page = new Page<>();
        page.setCurrentIndex(pageIndex);
        page.setPageSize(pageSize);
        //计算总页数
        page.setTotalPage(count);
        //封装总条数
        page.setTotal(count);
        page.setList(list);
        //封装当前页面
        page.setPageIndex();
        return page;
    }

}
